package sudoku.data;

import java.util.ArrayList;
import java.util.List;

public class SudokuButton {

  private String number;

  private java.awt.Color v2rv;

  private boolean abiNupp;

  private List<List<SudokuButton>> seotud;

  private List<String> tehnikad;

  private boolean kandidaadid[];

  private int colors[];

  private int i;

  private int j;

  public SudokuButton(java.awt.Color color, int i, int j) {
    number = " ";
    v2rv = color;
    abiNupp = false;
    seotud = new ArrayList<List<SudokuButton>>();
    this.i = i;
    this.j = j;
  }

  public int add(List<SudokuButton> buttons) {
    seotud.add(buttons);
    return seotud.size() - 1;
  }

  public void add(SudokuButton button, int i) {
    seotud.get(i).add(button);
  }

  @Override
  public boolean equals(Object o) {
    SudokuButton b = (SudokuButton) o;
    if (b == null) {
      return false;
    }
    return i == b.getI() && j == b.getJ();
  }

  public int[] getColors() {
    return colors;
  }

  public int getColor(int kan) {
    return colors[kan];
  }

  public int getColor(Integer kan) {
    return colors[kan.intValue()];
  }

  public int getI() {
    return i;
  }

  public int getJ() {
    return j;
  }

  public boolean[] getKandidaadid() {
    return kandidaadid;
  }

  public int getKandidaat() {
    for (int i = 0; i < kandidaadid.length; i++) {
      if (kandidaadid[i]) {
        return i;
      }
    }

    return 0;
  }

  public boolean getKandidaat(int i) {
    return kandidaadid[i];
  }

  public int getKandidaate() {
    int a = 0;
    for (int i = 0; i < kandidaadid.length; i++) {
      if (kandidaadid[i]) {
        a++;
      }
    }

    return a;
  }

  public String getNumber() {
    return number;
  }

  public List<List<SudokuButton>> getSeotud() {
    return seotud;
  }

  public List<String> getTehnikad() {
    return tehnikad;
  }

  public java.awt.Color getV2rv() {
    return v2rv;
  }

  public boolean isAbiNupp() {
    return abiNupp;
  }

  public void removeKandidaat(int i) {
    kandidaadid[i] = false;
  }

  public void removeKandidaat(Integer i) {
    kandidaadid[i.intValue()] = false;
  }

  public void resetSeotud() {
    seotud = new ArrayList<List<SudokuButton>>();
  }

  public void restoreKandidaat(int i) {
    kandidaadid[i] = true;
  }

  public void setAbiNupp(boolean abiNupp) {
    this.abiNupp = abiNupp;
  }

  public void setColor(int i, int col) {
    colors[i] = col;
  }

  public void setColors(int colors[]) {
    for (int i = 0; i < colors.length; i++) {
      colors[i] = -1;
    }

    this.colors = colors;
  }

  public void setKandidaadid(boolean kandidaadid[]) {
    for (int i = 0; i < kandidaadid.length; i++) {
      kandidaadid[i] = true;
    }

    this.kandidaadid = kandidaadid;
  }

  public void setKandidaat(int i) {
    for (int j = 0; j < kandidaadid.length; j++) {
      kandidaadid[j] = j == i;
    }

  }

  public void setNumber(String number) {
    this.number = number;
  }

  public void setSeotud(List<List<SudokuButton>> seotud) {
    this.seotud = seotud;
  }

  public void setTehnikad(List<String> tehnikad) {
    this.tehnikad = tehnikad;
  }

  public void setV2rv(java.awt.Color v2rv) {
    this.v2rv = v2rv;
  }
}